<?php
/***************************************************************************
 *
 *   copyright            : (C) 2011 Nathan Clemons
 *
 *   $Id: scbugfilter.php 129 2011-06-08 18:25:15Z stormerider $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$scbugfilter = array(
            'TYPE'		=>      'filter',
			'NAME'		=>      'StormChat Bugs Quicklink Filter',
			'VERSION'	=>      '1.0.0',
			'CREDIT'	=>      'StormeRider',
			'FUNC'		=>      'pluginSCBugsFilter',
			'HELP'		=>      'pluginSCBugsFilterHelp'
		);
$plugins[]	= $scbugfilter;

function pluginSCBugsFilterHelp($help) {
	global	$scbugfilter;

	$help['scbug']  = array('bug:[number]',
				            'Shows a chat-friendly link to the Google Code bug #[number] on the StormChat project.' .
				            pluginCredit($scbugfilter)
				          );

	return $help;
}

function pluginSCBugsFilter($msg) {
	global	$db;
	global	$dbprefix;
	
	// bug:whatever should translate to:
	//    <a target="_blank" href="http://code.google.com/p/stormchat/issues/detail?id=[whatever]">StormChat Bug #[whatever]</a>
	
	if (eregi("bug:", $msg)) {
		$msg	= eregi_replace("bug:([[:alnum:]]+)", "<a href=\" http://code.google.com/p/stormchat/issues/detail?id=\\1\" target=\"_blank\">StormChat Bug #\\1</a>", $msg);
	}
	
	return $msg;
}

?>
